"""
Copyright (c) 2022 Huawei Technologies Co.,Ltd.

openGauss is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:

          http://license.coscl.org.cn/MulanPSL2

THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
"""
"""
Case Type   : AI
Case Name   : \h predict by查询语法
Create At   : 2022/08/23
Owner       : @zou_jialiang050
Description :
    1.\h predict by查询语法
Expect      :
    1.返回语法说明
History     :
"""

import os
import unittest
from testcase.utils.CommonSH import CommonSH
from testcase.utils.Logger import Logger


class AI(unittest.TestCase):
    def setUp(self):
        self.logger = Logger()
        self.primary_sh = CommonSH('PrimaryDbUser')

    def test_ai(self):
        self.logger.info(f'-----{os.path.basename(__file__)} start-----')
        step1 = 'step1:\h predict by查询语法  expect:返回语法说明'
        self.logger.info(step1)
        select_describe = self.primary_sh.execut_db_sql(f'''\h predict by;''')
        self.logger.info(select_describe)
        self.assertIn('Command:     PREDICT BY', select_describe, "执行失败" +
                      step1)
        self.assertIn('Description: Use a trained model to perform inference '
                      'tasks', select_describe, "执行失败" + step1)
        self.assertIn('PREDICT BY model_name [ (FEATURES attribute '
                      '[, attribute] +]) ];', select_describe, "执行失败" +
                      step1)
        self.assertIn("Use the model in catalog 'gs_modelwarehouse' to "
                      "perform inference tasks.", select_describe, "执行失败" +
                      step1)

    def tearDown(self):
        self.logger.info('------无需清理环境----')
        self.logger.info(f'-----{os.path.basename(__file__)} end-----')
